#ifndef __DALELIB_GLUTWINDOW_H__
#define __DALELIB_GLUTWINDOW_H__

#include <string>
#include "graphics.h"

using namespace std;

namespace dalelib
{

class GlutWindow
{
private:

	string _name;
	int _pos_x;
	int _pos_y;
	int _width;
	int _height;

public:
	
	GlutWindow() { setPos(0,0); setSize(256,256); setName("GlutWindow"); }

	void setName(const string _Name) { _name = _Name; }

	void setPos(const int _Pos_x, const int _Pos_y) 
	{ 
		_pos_x = _Pos_x; 
		_pos_y = _Pos_y; 
	}

	void setSize(const int _Size_x, const int _Size_y) 
	{ 
		_width = _Size_x; 
		_height = _Size_y; 
	}

	void init(int argc, char **argv )
	{
		glutInit(&argc, argv);
		glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA );
		glutInitWindowPosition( _pos_x, _pos_y );
		glutInitWindowSize( _width, _height );
		glutCreateWindow( _name.c_str() );
	}
	void setDisplayFunc(void (*_Func)(void)) { glutDisplayFunc(_Func); }
	void setReshapeFunc(void (*_Func)(int,int)) { glutReshapeFunc(_Func); }
	void setKeyboardFunc(void (*_Func)(unsigned char,int,int)) { glutKeyboardFunc(_Func); }
	void setSpecialFunc(void (*_Func)(int,int,int)) { glutSpecialFunc(_Func); }
	void setMouseFunc(void (*_Func)(int,int,int,int)) { glutMouseFunc(_Func); }
	void setMotionFunc(void (*_Func)(int,int)) { glutMotionFunc(_Func); }
	void run() { glutMainLoop(); }
};

} // namespace dalelib

#endif

// *** examples ***



/*************************************************************************************
#include "glutwindow.h"

using namespace dalelib;

int SCREEN_WIDTH = 640;
int SCREEN_HEIGHT = 480;

void setup()
{

}

void setdown()
{
	exit(0);
}

void draw()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glutSwapBuffers();
	glutPostRedisplay();
}

void keys(unsigned char key,int x,int y)
{
	switch(key)
	{
	case 27: setdown(); break;
	}
}

int main(int argc,char *argv[])
{
	GlutWindow win;
	win.setPos(50,50); 
	win.setName("Blob");
	win.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
	win.init(argc,argv);
	win.setDisplayFunc(draw);
	win.setKeyboardFunc(keys);
	setup();
	win.run();
	return 0;
}
************************************************************************/